Skip to content

rust(feat): gate MCP tools with account feature flags at startup - #764

Merged
evan-sift merged 7 commits into
mainfrom
rust/mcp-feature-flag-gating
Aug 28, 2026
Merged

rust(feat): gate MCP tools with account feature flags at startup#764
evan-sift merged 7 commits into
mainfrom
rust/mcp-feature-flag-gating

Conversation

@evan-sift

@evan-sift evan-sift commented Aug 26, 2026

Copy link
Copy Markdown
Collaborator

Description

The MCP server now resolves the account's enabled feature flags at startup, using the configured API key, and excludes tools whose flag is not enabled. Most tools carry no flag and are always registered.

  • New sift_mcp::FeatureFlags: fetched once at startup via GET /api/v1/feature-flags/variants (5s timeout, bearer auth). A flag is enabled when its variant value is non-empty and not off.
  • A static registry in feature_flags.rs maps tool names to required flags; gated tools are removed from the router before serving, so they are absent from tools/list and rejected on call.
  • Fail-closed: if the fetch fails, the server starts normally with flag-gated tools disabled and logs a warning with the full error chain. Flag changes apply on MCP restart.
  • The fetch is functional traffic and still runs under --disable-nonessential-traffic (help text updated).
  • Removed the temporary Cargo feature that gated a tool domain at build time; those tools are now always built and gate at runtime instead.

Verification

  • cargo test -p sift_mcp: 311 passed. New coverage: wire-level fetch test (request line, bearer header, trailing-slash URI, 500 handling, response parse), registry drift guard, client-event invariant with all flags enabled, wire-level tools/list and tools/call for both flag states, fail-closed default behavior, enabled-semantics unit tests.
  • cargo check -p sift_cli, cargo fmt --all --check, cargo clippy --all-features (no new warnings) all pass.

with ff off:

image

with ff on:

image

@evan-sift
evan-sift requested a review from lineville August 27, 2026 23:31
@evan-sift
evan-sift marked this pull request as ready for review August 27, 2026 23:31
lineville
lineville previously approved these changes Aug 28, 2026

@lineville lineville left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, I think this might warrant a changelog entry as well but other than that lgtm!

Comment thread rust/crates/sift_cli/src/cmd/mcp.rs
@evan-sift
evan-sift requested a review from lineville August 28, 2026 00:52
@evan-sift
evan-sift enabled auto-merge (squash) August 28, 2026 00:57
@evan-sift
evan-sift merged commit e713170 into main Aug 28, 2026
22 checks passed
@evan-sift
evan-sift deleted the rust/mcp-feature-flag-gating branch August 28, 2026 01:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants